<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
        <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/base2.css">
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/css/css/style2.css">
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script>
		<title>账户管理-账号管理</title>
	</head>
	<body>
		<div class="page">
			<div class="header">
				<div class="header_top"></div>
				<div class="header_bottom clearfix">
					<div class="header_logo fl">
						<img src="${pageContext.request.contextPath}/images/images/index-logo.png">
					</div>
					<ul class="header_nav clearfix fl">
						<li>
							<a href="${pageContext.request.contextPath}/morder/waitOrderList.html" >订单管理</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath}/staff/queryAllList/1.html">家政人员管理</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath}/supplier/account.html" >财务管理</a>
						</li>
						<li>
							<a href="${pageContext.request.contextPath}/admin/accountInfo.html" class="on">账户管理</a>
						</li>
					</ul>
					<div class="header_user fr">
						<img src="${pageContext.request.contextPath}/images/images/user.png">欢迎您，<i>${ sessionScope.MANAGER_NAME} </i><a href="${pageContext.request.contextPath}/manager/loginout.html">【切换账号】</a>
					</div>
				</div>
			</div>
			<div class="main clearfix">
				<div class="main_menu fl">
					<%-- <div class="menu_name">
						<a href="${pageContext.request.contextPath}/admin/toPassword.html">
							<img src="${pageContext.request.contextPath}/images/images/xgmm.png">
							<p>修改密码</p>
						</a>
					</div>
					<div class="menu_name on">
						<a href="${pageContext.request.contextPath}/admin/list/1.html">
							<img src="${pageContext.request.contextPath}/images/images/zh_zhgl.png">
							<p>账号管理</p>
						</a>
					</div> --%>
					
					<div class="menu_name">
						<a href="${pageContext.request.contextPath}/admin/accountInfo.html">
							<img src="${pageContext.request.contextPath}/images/images/zh_zhxx.png">
							<p>账户信息</p>
						</a>
					</div>
					<div class="menu_name">
						<a href="${pageContext.request.contextPath}/admin/editPwd.html">
							<img src="${pageContext.request.contextPath}/images/images/xgmm.png">
							<p>修改密码</p>
						</a>
					</div>
					<div class="menu_name">
						<a href="${pageContext.request.contextPath}/admin/agreementInfo.html">
							<img src="${pageContext.request.contextPath}/images/images/hzxy.png">
							<p>合作协议</p>
						</a>
					</div>
					
					<div class="menu_name on">
						<a href="${pageContext.request.contextPath}/admin/supplierlist/1.html">
						<img src="${pageContext.request.contextPath}/images/images/zh_zhgl.png">
						<p>账号管理</p>
						</a>
					</div>	
					
				</div>
				<div class="main_cont fl">
					<div class="main_cont_top">
						<div class="main_inner">
							<div class="cont_top_title">当前位置：账户管理 > 账号管理</div>
						</div>
					</div>
					<div class="main_cont_bottom_zhgl">
						<div class="main_inner">
							<div class="caozuo_batch clearfix">
								<div class="batch fl mr25"><img src="${pageContext.request.contextPath}/images/images/delete.png" style="vertical-align: -1px;">
								<a onclick="datadel();">批量删除</a>
								</div>
								<a href="${pageContext.request.contextPath}/admin/toaddAdmin.html" class="batch fl"><img src="${pageContext.request.contextPath}/images/images/batch_add.png" style="vertical-align: -1px;">添加账号</a>
							</div>
							<table>
							    <tr>
							    	<th><input type="checkbox" class="checked" id="checkAll"></th>
							        <th>编号</th> 
							        <th>账号</th> 
							        <th>角色</th>
							        <th>创建时间</th>
							        <th>状态</th>
							        <th>操作</th>
							    </tr> 
							     <c:forEach items="${PAGE_BEAN.dataList}" var="admin">
							      <tr> 
							        <td><input type="checkbox" class="checked" name="idArray" id="idArray" value="${admin.id }"></td> 
							        <td>${admin.id }</td> 
							        <td>${admin.wAUsername }</td>
							        <td>
							        <c:if test="${admin.wARoleId eq 1}">
									渠道管理员
									</c:if>
									<c:if test="${admin.wARoleId eq 8}">
									平台管理员8
									</c:if>
									<c:if test="${admin.wARoleId eq 9}">
									平台管理员9
									</c:if>
									<c:if test="${admin.wARoleId eq 10}">
									家政商管理员
									</c:if>
									<c:if test="${admin.wARoleId eq 11}">
									非家政商管理员
									</c:if>
							        </td> 
							        <td><fmt:formatDate value="${admin.createTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td> 
							        <td>
							        <c:if test="${admin.status eq 0}">
									停用
									</c:if>
									<c:if test="${admin.status eq 1}">
									启用
									</c:if>
									</td>
							        <td><i>
							        <c:if test="${admin.status eq 0}">
									 <a onclick="qiyong(${admin.id })">启用</a>
									</c:if>
									<c:if test="${admin.status eq 1}">
									 <a onclick="tingyong(${admin.id })">停用</a>
									</c:if>
							        </i><i>
							       	<a onclick="deleteOne(${admin.id })"> 删除</a>
							        </i><i>
							        <a onclick="editPassword(${admin.id })">重置密码</a>
							        </i></td>
							     </tr> 
							    </c:forEach>
							   
							</table> 
							<%@ include file="/WEB-INF/views/page.jsp"%>
						</div>
					</div>
				</div>
			</div>
		</div>
		<script type="text/javascript">
		function deleteOne(id){
			if(id!=""){
				 $.ajax({
					 	url:"/admin/remove/"+id+".json",
						success: function(data){
							alert(data.info);
							window.location.reload();
						}
					});
			}
		}
		
		function qiyong(id){
			 if(id!=""){
				 $.ajax({
					 	url:"/admin/start/"+id+".json",
						success: function(data){
							alert(data.info);
							window.location.reload();
						}
					});
			 }
		}
		
		function tingyong(id){
			 if(id!=""){
				 $.ajax({
					 	url:"/admin/stop/"+id+".json",
						success: function(data){
							alert(data.info);
							window.location.reload();
						}
					});
			 }
		}
		
		function editPassword(id){
			 if(id!=""){
				 $.ajax({
					 	url:"/admin/editPass/"+id+".json",
						success: function(data){
							alert(data.info);
							window.location.reload();
						}
					});
			 }
		}
		
		
		/*渠道-删除*/
		function datadel(){
			    var chk_value =[];    
			      
				$('input[name="idArray"]:checked').each(function(){    
				   chk_value.push($(this).val()); 
				});
				
				if(chk_value.length==0){
					alert("请选择删除的账号！");
					return false;
				}
				  
				var param = "";
				for(var i = 0; i < chk_value.length; i++) {
					param += chk_value[i] + "-";
				}
				
				$.ajax(
						{url:"/admin/removeall/" + param + ".json",
						async:false,
						success: function(data){
							alert(data.info);
							window.location.reload();
						}
				});
		}
		
	    $("#checkAll").bind("click", function () {
	    	$("[name=idArray]:checkbox").prop("checked", this.checked);
	    });

		$("input[name='idArray']").click(function() {
		    var $subs = $("input[name='idArray']");
			$("#checkAll").prop("checked",$subs.length == $subs.filter(":checked").length ? true : false);
		});

		</script>
	</body>
</html>
